﻿@model FlexFlow.Model.WorkFlowForm

@using FlexFlow.Model
@using FlexFlow.Runtime

<link href="~/Assets/css/jquery-ui-1.10.3.custom.min.css" rel="stylesheet" />
<link href="~/Assets/css/tagmanager.css" rel="stylesheet" />
<link href="~/Assets/css/typeahead.css" rel="stylesheet" />
<script src="~/Assets/js/jquery.form.js"></script>
<script src="~/assets/js/jquery.validate.min.js"></script>
<script src="~/Assets/js/typeahead.bundle.js"></script>
<script src="~/Assets/js/flexflow-controls.js"></script>
<script src="~/Assets/js/tagmanager.js"></script>
<script src="~/Assets/js/handlebars.js"></script>
<div class="row">
    <form class="form-horizontal" role="form" id="frmForm">
        <div style="
    overflow: scroll;
">
            @{
                Html.RenderAction("Edit", new { formId = Model.Template, model = Model, readOnly = Request["readOnly"] != null });
            }

            @if (Request["readOnly"] == null)
            {
                <div class="col-md-offset-3 col-md-9">
                    <button class="btn btn-info" type="submit">
                        <i class="icon-ok bigger-110"></i>
                        提交
                    </button>

                    &nbsp; &nbsp; &nbsp;
                    <button class="btn" type="reset">
                        <i class="icon-undo bigger-110"></i>
                        重设
                    </button>
                </div>
            }
        </div>
    </form>
    @if (Request["readOnly"] == null)
    {
        <script>
            function doUpdateForm() {
                $("#frmForm").ajaxSubmit({
                    type: "POST",
                    url: "/FormAPI/UpdateContent",
                    data: {
                        formId: "@Model.Identity"
                    },
                    success: function (response, statusText) {
                        bootbox.dialog({
                            message: response.Message,
                            buttons: {
                                "success": {
                                    "label": "确定",
                                    "className": "btn-sm btn-primary"
                                }
                            }
                        });
                    }
                })
            }

            $('#frmForm').validate(buildOpt(doUpdateForm, function () { }));

        </script>
    }
</div>